package br.edu.sistemaacademico.command;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class CommandFrmProperties implements CommandFrm{

     private final String FILE = "/br/edu/sistemaacademico/command/frm.properties";

    private Properties prop = new Properties();

    public CommandFrmProperties() {
          InputStream is = getClass().getResourceAsStream(FILE);
        try {
            prop.load(is);
            is.close();
        } catch (IOException ex) {
        System.out.println(ex);
        }
    }
    public Command createCommand(String cmd) {
       Command command   = null;
       String  className = prop.getProperty(cmd);

       try {
          Class  clazz = Class.forName(className.toString());
          //Class  clazz = Class.forName("estagio.frmCadastroCliente");
          Object obj   = clazz.newInstance();

          command = (Command) obj;
       }
       catch (Exception ex) { ex.printStackTrace(); }
       return command;
    }
}
